using System;
using System.Text;

namespace Needle.Utils {
    /// <summary>
    /// String utilities
    /// </summary>
    public static class Strings {

        /// <summary>
        /// Changes the first character of the string to lowercase.
        /// </summary>
        public static string LowerCaseFirstChar(string text) {
            Ensure.NotNull(text,"text");
            if (text.Length < 1 || Char.IsLower(text[0])) {
                return text;
            }
            StringBuilder sb = new StringBuilder(text);
            sb[0] = Char.ToLower(sb[0]);
            return sb.ToString();
        }

        /// <summary>
        /// Changes the first character of the string to uppercase.
        /// </summary>
        public static string UpperCaseFirstChar(string text) {
            Ensure.NotNull(text, "text");
            if (text.Length < 1 || Char.IsUpper(text[0])) {
                return text;
            }
            StringBuilder sb = new StringBuilder(text);
            sb[0] = Char.ToUpper(sb[0]);
            return sb.ToString();
        }

    }
}
